import { defineStore } from "pinia";

import { Names } from "./store_name";

export const useTestStore = defineStore(Names.TEST, {
  state: () => {
    return {
      name: "鱼钓猫",
      habit: "小鱼干",
      num: 1,
    };
  },
  // 类似 computed 计算属性
  getters: {
    double(state) {
      return state.num * 2;
    },
  },
  actions: {
    change(val: string) {
      console.log(this);
      this.name += val;
    },
    reset() {
      this.$reset();
    },
  },
});
